<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * @version $Id: edit_results_advanced.tpl.php 1151 2008-06-24 15:07:32Z julienv $
 * @package Joomleague
 * @copyright Copyright (C) 2007  JoomLeague
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see _joomleague_license.txt
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 
global $mainframe, $htmlHelper;

?>

<a name="jl_top" id="jl_top"></a>
<!-- Header with Project Name-->
<?php 
if ($results_config['show_project_heading'] > 0 OR $overall_config['show_project_heading'] > 0) 
{ ?>
  <div class="componentheading" <?php if ($results_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") echo 'style="float:left;"';?>><?php echo $htmlHelper->showTitle($joomleague, $overall_config['project_heading_type']); ?></div>
  <!-- Druckfunktion -->
  <?php 
  if ($results_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") 
  {
    $htmlHelper->PrintIcon( $row, $params, false, '' );
  }
  ?>
  <!-- Druckfunktion Ende -->
  <?php 
} 
?>
<!-- Header END -->

<!-- section header e.g. ranking, results etc. -->

<?php 
// load javascripts
$mainframe->addCustomHeadTag( '
	<script src="'. JL_URL_FOLDER.'/js/JL_eventsediting.js" type="text/javascript"></script>
	<!-- import the calendar script -->
  <script language="javascript" type="text/javascript" src="'._JOOMLA_JL_LIVE_SITE.'/includes/js/calendar/calendar_mini.js"></script>
  <!-- import the language module -->
  <script language="javascript" type="text/javascript" src="'._JOOMLA_JL_LIVE_SITE.'/includes/js/calendar/lang/calendar-en.js"></script>
	' );
?>
<div>
<table class="contentpaneopen" style="width:auto;">
	<tr>
		<td class="contentheading">
    <?php 
    if ($current_round>0) {
      $htmlHelper->show_matchdays_title(_JL_RESULTS, $rounds[$current_round-1]->id, $results_config);
	    if (defined('JL_SHOW_EDIT_ICON')) $htmlHelper->show_edit_icon($current_round, $jl_func);
	    $editall = false;
    }
    else {
      if (defined('JL_SHOW_EDIT_ICON')) {
        echo _JL_RESULTS_EDIT_ALL;
        $htmlHelper->show_edit_icon($current_round, $jl_func);
        $editall = true;
      }
    }
    ?>
    </td>
  </tr>
<?php
 if ((isset($overall_config['use_jl_substitution']) && $overall_config['use_jl_substitution']) || (isset($overall_config['use_jl_events']) && $overall_config['use_jl_events'])) { ?>
  <tr>
    <td>
  		<table>
  		<tr><td id="matchesdropdown" align="right">
        <?php
          // games dropdown
        	$mdd[] = mosHTML::makeOption( 0, _JL_ADMIN_EDIT_LIST_MATCHES_TITLE );
        	foreach( $matches as $match ) 
          {
            $hometeam = $resultTeams[$match->matchpart1];
            $guestteam = $resultTeams[$match->matchpart2];
            $mdd[] = mosHTML::makeOption( _JOOMLA_JL_LIVE_SITE . "/" .JL_COMPONENT_LINK_NOHTML
                            . "&amp;func=editEvents&amp;p=".$joomleague->id
  		 			                . "&amp;mid=".$match->match_id, 
  		 			   $hometeam->$results_config['names']." - ".$guestteam->$results_config['names'] );
            
          }
          $RosterEventMessage = (isset($overall_config['use_jl_substitution']) && $overall_config['use_jl_substitution']) ? _JL_STARTING_ROSTERS : '';
          if (isset($overall_config['use_jl_events']) && $overall_config['use_jl_events']) {
            if (isset($overall_config['use_jl_events']) && $overall_config['use_jl_substitution']) $RosterEventMessage .= ' / ';
            $RosterEventMessage .= _JL_ADMIN_EDIT_LIST_MATCHES_EVENTS;
          }
          $RosterEventMessage .= ($RosterEventMessage != '') ? ': ' : '';
          echo $RosterEventMessage;
		      echo mosHTML::selectList( $mdd, 'mdd', 
		      					'id="mdd" class="inputbox" onchange="jl_load_new_match_events(this, \'myeventscontainer\')"',
		      					'value', 'text', '0' );
		      unset($mdd);		
    		?>
  		</td></tr>
  		</table>
  		<div id="log_res"></div>
  		<div id="myeventscontainer"></div>
    </td>
  </tr>
<?php
 }
?>
  
  <tr>
    <td>
      <form name="adminForm" id="adminForm" method="post" action="<?php echo JL_COMPONENT_LINK.JL_ITEMID_SUFFIX;?>">
      <input type="hidden" name="p" value="<?php echo $joomleague->id;?>" />
      <input type="hidden" name="r" value="<?php echo $current_round;?>" />
      <input type="hidden" name="sel_r" value="<?php echo $current_round;?>" />
      <input type="hidden" name="option" value="com_joomleague" />
      <input type="hidden" name="func" value="saveResults" />
      <input type="hidden" name="oldfunc" value="<?php echo $jl_func;?>" />
      <input type="hidden" name="boxchecked" id="boxchecked" value="0" />
      <input type="hidden" name="checkmycontainers" id="checkmycontainers" value="0" />
      <?php
      if ($joomleague->current_round_auto==0) {
        echo '<div style="text-align:right"><b>'._JL_RESULTS_SET_MATCHDAY.'</b>'
        .$joomleague->roundsdropdown($current_round, count($rounds)).'</div>';
        }
      ?>

<!-- Main START -->
<table border="0" cellpadding="3" cellspacing="0">
<?php
if ( count($matches) > 0 ) 
{
	if ( isset( $overall_config['edit_results_below'] ) && $overall_config['edit_results_below']==1 ) {
	  $results_config['results_below']=1;
	}
	else {
	  $results_config['show_match_number']=1;
	}
  $results_config['show_events']=0;
  $results_config['show_division']=0;
  $results_config['show_playground']=1;
  $results_config['show_logo_small']=0;
  

  $htmlHelper->resultsColspan($results_config, 1);

  $i=0;
  $previousdate = '';
  $previous_roundcode = 0;
  foreach( $matches as $match ) 
  {
    $results_config['class'] = ($i % 2)? $results_config['style_class1'] : $results_config['style_class2'];
    
    if (     defined('JL_EDIT_MODE') 
          && ( $match->checked_out==0 || $match->checked_out == $my->id )
          && $joomleague->isMatchAdmin($match->match_id, $my->id) )
    {
      // if we areediting all gamedays at once, display the round names.
      if ( $editall && $previous_roundcode != $match->roundcode ) 
      {
        ?>
      	<tr class="<?php echo $results_config['class'];?>">
        	<td colspan="<?php echo $results_config['colspan'];?>" class="sectiontableheader">
        	  <?php 
            echo $match->roundcode . ' - ' . $match->roundname;
            ?>
        	</td>
      	</tr>
        <?php
      }
      $htmlHelper->newDayHeading( $match->match_date, $previousdate, $results_config );      
      $htmlHelper->editable_row($match, $resultTeams, $i, $results_config);
      // div for match details.
      ?>
    	<tr style="margin:0;padding:0" class="<?php echo $results_config['class'];?>">
      	<td colspan="<?php echo $results_config['colspan'];?>" style="margin:0;padding:0">
      	  <div id="details<?php echo $match->match_id;?>" style="display:none;margin:0;padding:0"></div>
      	</td>
    	</tr>
      <?php
    }
    $i++;
  }
}
?>          
</table>

<div align="center">
  <input type="submit" class="button" name="saveResults" value="<?php echo _JL_SAVE;?>" onclick="document.getElementById('checkmycontainers').value=0;" />
</div>
<!-- Main END -->

<input type="hidden" class="button" name="save_data" value="1" />
</form>
     </td>
   </tr>
 </table>
</div>

<!-- Matchdays navigation Output  -->
<?php 
if ( isset($pageNav) ) 
{ 
  ?>
  <table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
    <tr>
      <td align="center">
        <?php 
        echo $pageNav;
        ?>
      </td>
    <tr>
      <td align="center">
        <?php 
        echo '<a href="'.sefRelToAbs(JL_COMPONENT_LINK.'&amp;func=editResults&amp;p='.$joomleague->id).'">';
        echo _JL_RESULTS_EDIT_ALL_ROUNDS;
        echo '</a>';
        ?>        
      </td>
    </tr>
  </table>
  <?php 
}
?>
<!-- Matchdays navigation Output END --> 

<!-- Print Button START -->
<?php if ($results_config['show_back_button'] > 0 OR $overall_config['show_back_button'] > 0) {;?>
<?php if ($results_config['show_back_button'] == "1" OR $overall_config['show_back_button'] == "1") echo '<div align="left">'; else echo '<div align="right">';?>
<?php
$params = & new mosParameters( '' );
$params->def( 'back_button', true );
$params->def( 'popup', false );
mosHTML::BackButton( $params );
  echo "</div>";
};?>
<!-- Print Button END -->
